package notification

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method 'POST'
        url("/api/notifications")
        headers {
            contentType(applicationJsonUtf8())
            header("id", 1)
        }
        body("""
             {
                    "receiverId":1,
                    "programId":1,
                    "assignmentId":1,
                    "isRead":false,
                    "message":"message test",
                    "url":"http://www.message.com",
                    "createTime":"2018-09-29",
                    "type":"STUDENT_MODIFY_ASSIGNMENT_STATUS",
             }
        """)
        bodyMatchers {
            jsonPath('$.receiverId', byRegex(number()))
            jsonPath('$.programId', byRegex(number()))
            jsonPath('$.assignmentId', byRegex(number()))
            jsonPath('$.isRead', byRegex(anyBoolean()))
            jsonPath('$.url', byRegex(nonEmpty()))
            jsonPath('$.createTime', byRegex(nonEmpty()))
            jsonPath('$.type', byRegex(nonEmpty()))
        }
    }
    response {
        status 201
    }
}
